<?php

namespace app\controllers;

use app\logic\FieldLogic;
use yii\web\HttpException;
use app\components\Controller;

/**
 * 字段控制器
 */
class FieldController extends Controller
{
    protected function verbs()
    {
        return [
            'index' => ['GET'],
            'create' => ['POST'],
            'update' => ['POST'],
            'delete' => ['POST'],
            'status' => ['POST'],
            'auth' => ['POST'],
            'get-info' => ['GET'],
            'get-param' => ['GET'],
        ];
    }

    /**
     * 列表 字段
     * @return array
     * @throws HttpException
     */
    public function actionIndex()
    {
        return FieldLogic::index(getParams());
    }

    /**
     * 创建 字段
     * @throws HttpException
     */
    public function actionCreate()
    {
        return FieldLogic::create(getParams());
    }

    /**
     * 编辑 字段
     * @throws HttpException
     */
    public function actionUpdate()
    {
        return FieldLogic::update(getParams());
    }

    /**
     * 删除 字段
     * @throws HttpException
     * @throws \Throwable
     */
    public function actionDelete()
    {
        return FieldLogic::delete(getParams());
    }

    /**
     * 禁用、启用 字段
     * @throws HttpException
     */
    public function actionStatus()
    {
        return FieldLogic::status(getParams());
    }

    /**
     * 权限选择 字段
     * @throws HttpException
     */
    public function actionAuth()
    {
        return FieldLogic::auth(getParams());
    }

    /**
     * 编辑时的信息 字段
     * @return array
     * @throws HttpException
     */
    public function actionGetInfo()
    {
        return FieldLogic::getInfo(getParams());
    }

    /**
     * 表单参数（ 添加、编辑 调用 ）
     * @return array
     */
    public function actionGetParam()
    {
        return FieldLogic::getParam();
    }
}